home *** CD-ROM | disk | FTP | other *** search
/ HPAVC / HPAVC CD-ROM.iso / pc / RGASM.RAR / ASMCODE.EXE / CHAPT12 / CCOMM.C < prev    next >
Encoding:
C/C++ Source or Header  |  1994-08-27  |  2.7 KB  |  64 lines

  1.  
  2. /**********************************************************************
  3. *
  4. *  Issuing an MS-DOS command from within C program
  5. *
  6. *  Author: A.I.Sopin, Voronezh University, Voronezh, Russia  1992
  7. *
  8. *  External functions used (the C60S.LIB library):
  9. *
  10. *  DIAM04,  CCOLOR, WINC07, DOSCOM
  11. *
  12. **********************************************************************/
  13.  
  14. #include <stdio.h>
  15. #include <dos.h>
  16.  
  17. extern void CCOLOR (int  M, int  N, int  C);
  18. extern void DIAM04 (int OP, int M, int N, char *Tp, int L, int U, int V,
  19.                     int *Qp, int *Sp, unsigned char *Wp, char *Ip);
  20. extern void DIAM24 (unsigned char *Wp);
  21. extern int  DOSCOM (char *Comand);
  22. extern void WINC07 (int M, char *T, int L, int V, int *Q, int *S, 
  23.              unsigned char *Wp, char *I, int RL, int RR);
  24.  
  25. union  REGS  regs;
  26.  
  27. void main ()
  28.  
  29. {
  30. static int  Q, S, j;
  31. static unsigned  char W[4];
  32. static char  TEXT23 [ ] ={ "Enter command line or press ESC to exit " };
  33. static char  TEXT1 [ ] ={  "Input and processing an MS-DOS command   "
  34.                            "  Author:  A.I.Sopin,   Voronezh, 1992   "  };
  35. static char  COMSTR [81];
  36. /*-------------------------------------------------------------------------*/
  37. /*  Input a command line                                                   */
  38.  
  39.     *(W+1) = 0;                      /*  clear the code of the key pressed */
  40.     while (1)                        /*  permanent cycle (wait for key)    */
  41.     {
  42.       CCOLOR (1, 25, 0x07);          /*  clear screen and set up color    */
  43.       DIAM04 (1, 1, 1, TEXT1, 80, 0, 0, &Q, &S, W, 0);
  44.       DIAM04 (1, 23, -23, TEXT23, 80, 24, 2, &Q, &S, W, 0);
  45.       for (j = 1; j <= 79; j++)  *(COMSTR + j) = ' ';    /*  clear command
  46.                                                              line buffer   */
  47.  
  48.       *COMSTR = '>';                 /*  output command prompt             */
  49.       WINC07 (24, COMSTR, 80, 2, &Q, &S, W, 0, 2, 80);
  50.       if (*(W+1) == 1)  break;       /*  Esc - end of program's work       */
  51. /*-------------------------------------------------------------------------*/
  52. /*  Processing the command entered  (ESC - exit)                           */
  53.       DOSCOM (COMSTR+1);             /* enter and process an MS-DOS command */
  54.       DIAM04 (1, 25, -25, "Press any Key (Esc -Exit)",
  55.       80, 0, 0, &Q, &S, W, 0);
  56.       DIAM24 (W);                    /*  waiting for pressing any key      */
  57.       if (*(W+1) == 1)  break;       /*  Esc - exit program                */
  58.     } /* End  while (*(W+1) != 1) */
  59. /*-------------------------------------------------------------------------*/
  60. /*  Completion of the work (after pressing Esc)                            */
  61.       exit (0);
  62. }  /* End  main  */
  63.  
  64.